跳到主要内容

Claude 原生接口调用

POST /v1/messages

Body 请求参数

{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}

请求参数

名称位置类型必选说明
x-api-keyheaderstringBearer AIHUBMIX_API_KEY
Content-Typeheaderstringnone
bodybodyobjectnone
» modelbodystringnone
» messagesbody[object]none
»» rolebodystringnone
»» contentbodystringnone
» max_tokensbodynumbernone

返回示例

200 Response

{
"id": "msg_013Uf6CwwyjSe35n3yVaPbLM",
"type": "message",
"role": "assistant",
"model": "claude-3-5-sonnet-20241022",
"content": [
{
"type": "text",
"text": "That's one of humanity's most enduring and complex philosophical questions! While there's no universal answer, I aim to explore such questions thoughtfully while acknowledging their complexity. I try to focus on having meaningful conversations and helping where I can. What does meaning in life mean to you?"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 14,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 61
}
}

返回结果

状态码状态码含义说明数据模型
200OKnoneInline

返回数据结构

数据模型